package cn.com.cetccst.sdk.modelbase;

import static cn.com.cetccst.sdk.modelbase.BaseResp.ErrCode.*;

import android.content.Context;

import java.util.HashMap;
import java.util.Map;

import cn.com.cetccst.sdk.R;

public class ErrorMessage {

    private static Map<Integer, String> errorMessages;

    public static void init(final Context context) {
        errorMessages = new HashMap() {
            {
                if (context != null) {
                    put(ERR_USER_CANCEL, context.getString(R.string.ss_opensdk_user_cancel));
                    put(ERR_USER_DENIED, context.getString(R.string.ss_opensdk_user_denied));
                    put(ERR_NO_USER, context.getString(R.string.ss_opensdk_no_user));
                    put(ERR_NO_NETWORK, context.getString(R.string.ss_opensdk_no_network));
                    put(ERR_AUTH_FAILED, context.getString(R.string.ss_opensdk_auth_failed));
                    put(ERR_NOT_SUPPORT, context.getString(R.string.ss_opensdk_no_support));
                    put(ERR_WORK_BENCH_ERROR, context.getString(R.string.ss_opensdk_wb_error));
                    put(ERR_APP_KEY_NULL, context.getString(R.string.ss_opensdk_app_key_null));
                    put(ERR_APP_NOT_ADD, context.getString(R.string.ss_opensdk_app_not_add));
                    put(ERR_PARAMETER_NULL, context.getString(R.string.ss_opensdk_parameter_null));
                    put(ERR_SDK_ERROR, context.getString(R.string.ss_opensdk_inner_error));
                    put(ERROR_APP_KEY_ERROR, context.getString(R.string.ss_opensdk_app_key_error));
                    put(ERROR_APP_NOT_INSTALL, context.getString(R.string.ss_opensdk_app_not_install));
                    put(ERROR_OPENSDK_VERSION_TOO_LOW, context.getString(R.string.ss_opensdk_version_too_low));
                    put(ERROR_PERMISSION_WRITE_SDCARD, context.getString(R.string.ss_opensdk_no_permission_write));
                    put(ERROR_PERMISSION_LOCATION, context.getString(R.string.ss_opensdk_no_permission_location));
                    put(ERROR_PERMISSION_CAMERA, context.getString(R.string.ss_opensdk_no_permission_camera));
                }
            }
        };
    }

    public static String getErrorMessage(int errorCode) {
        return errorMessages.get(errorCode);
    }

    public static Map<Integer, String> getMap(){
        return errorMessages;
    }
}
